package com.yunyao.web.controller;

import com.yunyao.common.dto.UserDto;
import com.yunyao.common.web.util.PageResult;
import com.yunyao.common.web.util.YResult;
import com.yunyao.framework.dto.user.UserDeleteDto;
import com.yunyao.framework.dto.user.UserSaveDto;
import com.yunyao.framework.service.UserService;
import com.yunyao.framework.vo.user.UserDeptVO;
import com.yunyao.framework.vo.user.UserInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xingjishuai
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;


    @GetMapping("/dept/list")
    public YResult<PageResult<UserDeptVO>> getDeptList(UserDto userDto) {
        return userService.getDeptList(userDto);
    }

    @GetMapping("/list")
    public YResult<PageResult<UserDeptVO>> pageList(UserDto userDto) {
        return userService.pageList(userDto);
    }
    @GetMapping("/info")
    public YResult<UserInfoVO> getByIdInfo(UserDto userDto) {
        return userService.getByIdInfo(userDto);
    }
    @PostMapping("/save")
    public YResult<String> save(@RequestBody UserSaveDto userSaveDto) {
        return userService.save(userSaveDto);
    }
    @PostMapping("/sync/mdm")
    public YResult<String> syncMdm(@RequestBody UserDto userDto) {
        return userService.syncMdm(userDto);
    }
    @PostMapping("/delete/id")
    public YResult<String> deleteById(@RequestBody UserDeleteDto userDeleteDto) {
        return userService.deleteById(userDeleteDto);
    }

}
